package headfirst.designpatterns.factory.a_cars_simplefactory1.z_run_test;

import headfirst.designpatterns.factory.a_cars_simplefactory1.car.Benz;
import headfirst.designpatterns.factory.a_cars_simplefactory1.car.Car;
import headfirst.designpatterns.factory.a_cars_simplefactory1.factory.DriverSimplyFactory;

import java.io.IOException;

/**
 * @description: 老板（使用者）测试
 * @author: 陈家盛
 * @date: 2022/6/22 10:25
 * @version: 1.0
 */
class BossCallTest {

    public static void main(String[] args) throws IOException {


        /**
         * 直接通过工厂创建，最简单的解耦方式
         * 即将new 实例化交给工厂创建
         */
        Car car = new Benz();
        car.setName("benz1");
        car.drive();

        /**
         * 使用者只需知道开车即可
         */
        // 老板告诉司机我今天坐 奔驰
        Car car1 = DriverSimplyFactory.createCar("benz");
        car1.setName("benz");
        // 司机开着 奔驰 出发
        car1.drive();


        // 老板告诉司机我今天坐 宝马
        Car car2 = DriverSimplyFactory.createCar("Bmw");
        car2.setName("Bmw");
        // 司机开着 宝马 出发
        car2.drive();


    }
}
